import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import { BrowserRouter as Router } from 'react-router-dom';
import store from '@/store';
import { Provider } from 'react-redux'; // 引入react-redux的提供者，作用是提供上下文把store传给所有的子孙节点
import zhCN from 'antd/locale/zh_CN'   //引入中文包
import { ConfigProvider } from 'antd';  //引入antd的配置上下文

const root = ReactDOM.createRoot(document.getElementById('root'));
const main = () => { // 封装的渲染页面
  root.render(
    // <React.StrictMode>
    // 提供一个全局的store传给所有的子孙节点
    <ConfigProvider locale={zhCN}>
      <Provider store = { store }>
        <Router>
          <App />
        </Router>
      </Provider>
    </ConfigProvider>
    // </React.StrictMode>
  );
}
main();

// 订阅store，只要store的state有改变，就会执行回调函数
store.subscribe(main)  // 重新渲染页面

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
